<template>
  <CommonPanel title="车辆出入实时数据">
    <div class="content-box" style="height: 100%;">
      <div style="color: #fff;height: 100%;" class="flex-x" >
        <!-- <div style="text-align: center,">车辆出入实时数据</div> -->
      <div class="main-box">
      <div class="people_card"  v-for="item,index in allData" :key="index">
        <div style="position: relative;">
        <div class="image">
          
        <img :src="apiKey+item.vehiclePicUri" alt="" style="width: 100%">
        <div style="margin-top: 4px;">
            <span style="padding: 2px 4px;background-color: #16539c;">{{item.plateNo}}</span> 
        </div>
        <div style="margin:  10px 0;">{{ item.crossTime }}</div>
        </div>
        <div class="title">{{ item.entranceName }}</div>

        <div style="position: absolute;top: 0;left: 0;width: 15%;height: 15%;display: flex;justify-content: center;align-items: center;background: #2e5787;">
        <span>  {{ item.inAndOutType===1?"进":"出" }} </span>
        </div>
      </div>
      </div>

    </div>
      </div>
    </div>
  </CommonPanel>
</template>

<script setup>
import { computed, onMounted, ref, watch } from "vue";
import man_1 from '@/assets/man_1.png'
import { defineProps } from "vue";
// const env = loadEnv(mode, process.cwd());
// const { VITE_IMAGE_URL } = env;
const props = defineProps({
  data: Object
});

const allData = ref([
]);

let apiKey;

    onMounted(() => {
      // 在这里访问环境变量
      apiKey = import.meta.env.VITE_IMAGE_URL || process.env.VITE_IMAGE_URL;
    });

const getDomainName=()=>{
  const currentUrl = window.location.href;
    const urlParts = new URL(currentUrl);
    const extractedDomain = urlParts.host.includes(':')
     ? urlParts.origin
      : urlParts.hostname;
   
      return extractedDomain
}

watch(() => props.data, (newData) => {
      if (newData) {
        allData.value= newData.cross_records?.map(item=>{
          return item
        })
        allData.value = allData.value.slice(0,7);
      }
    });

</script>

<style lang="scss" scoped>
.main-box {
  display: flex;
  box-sizing: border-box;
  padding: 10px 6px;
  // padding-top: 16px;
 
  height: 80%;
  // display: grid;
  // grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
  justify-content: center;
  grid-column-gap: 30px;
  width: 70%;
  margin: 10px auto;
  & > div {
    background: url('../../../assets/image/people.png') no-repeat center 0px;
    background-size: contain;
  }
  .image{
    position: relative;

    .back{
      position: absolute;
      bottom: 0;
      left: 0;
      background: rgba($color: #000000, $alpha: 0.2);
      color:white;
      font-size: 16px;
      width: 100%;
      padding: 10px 20px;
    }
  }
  .people_card{
    color: white;
    font-size: 14px;
    padding:10px 24px;
   
   .title{
    opacity: 0.5;
    margin-top: 10px;
   }
   .area{
    margin-top: 20px;
    font-size: 16px;
   }
  }
}
</style>